Component({
  properties: {
    units: {
      type: Array,
      value: []
    },
    isEn: {
      type: Boolean,
      value: false
    },
    subed: {
      type: Boolean
    }
  },
  methods: {
    onUnitClick(e) {
      let dataset = e.currentTarget.dataset;
      let unit = dataset.unit;
      if (!this.data.subed && !unit.hasFreeTopics){
        wx.showToast({
          title: '您尚未订阅对应课程',
          icon: 'none',
          duration: 2000
        })
        return;
      }
      this.triggerEvent('unitTap', unit);
    },
    onLessonClick(e) {
      let dataset = e.currentTarget.dataset;
      let lesson = dataset.lesson;
      if (!this.data.subed && !lesson.hasFreeTopics){
        wx.showToast({
          title: '您尚未订阅对应课程',
          icon: 'none',
          duration: 2000
        })
        return;
      }
      this.triggerEvent('lessonTap', dataset);
    }
  }
})